﻿@model MvcMovieCollection.Models.MoviesViews

@{
    ViewBag.Title = "Movies";
}

<h1>Movies</h1>

<br />

@using (Html.BeginForm())
{   
    <div>
        <fieldset>
            <legend>Search for Movie</legend>
            
            <div class="editor-label">
                @Html.LabelFor(m => m.Movie.Title)
            </div>
            <div class="editor-field">
                @Html.TextBoxFor(m => m.Movie.Title)
                @Html.ValidationMessageFor(m => m.Movie.Title)
            </div>

            <div class="editor-label">
                @Html.LabelFor(m => m.Movie.Description)
            </div>
            <div class="editor-field">
                @Html.TextAreaFor(m => m.Movie.Description, new {cols = "30", rows = "10" })
                @Html.ValidationMessageFor(m => m.Movie.Description)
            </div>

            <div class="editor-label">
                @Html.LabelFor(m => m.Movie.Genre)
            </div>

            <div class="editor-field">
                @Html.DropDownListFor(m => m.Genre.ID, new SelectList(ViewBag.ModelListGenres, "ID", "Name"))                
            </div>

            <p>
                <input type="submit", value="Search" />
            </p>

        </fieldset>
    </div>
}

@using (Html.BeginForm())
{
<table class="Movies">
    <tr>
        <th></th>
        <th>Title</th>
        <th>Description</th>
        <th>Release Date</th>
        <th>Genre</th>
    </tr>

    @foreach (MvcMovieCollection.Models.Movie movie in ViewBag.ModelListMovies)
    { 
        <tr>
            <td><h4>@Html.ActionLink("Edit", "EditMovie", new { id = movie.ID }) 
                | @Html.ActionLink("Delete", "DeleteMovie", new { id = movie.ID })</h4></td>
            <td><h4>@movie.Title</h4></td>
            <td>@movie.Description</td>
            <td><h4>@movie.ReleaseDate</h4></td>
            <td><h4>@movie.Genre</h4></td>
        </tr>
    }
</table>
}